//
//  SISSNetworkingManager+MineCooperation.m
//  SISSAPP
//
//  Created by 优房网 on 2017/5/25.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSNetworkingManager+MineCooperation.h"

@implementation SISSNetworkingManager (MineCooperation)

// 6.2.3  删除我发布的房源合作
- (void)deleteHouseCooperationWithHouseAhcrId:(NSString *)ahcrId successBlock:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"ahcrId":ahcrId
                                 };
    
    [kNetworkManager POSTWithURLString:URL_DELETE_MY_COOPERATION_HOUSE_DETAIL parameters:parameters success:^(id responseObject) {
        NSLog(@"6.2.3  删除我发布的房源合作: responseObject-->%@",responseObject);
        
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
    
}

// 6.2.4 删除我发布的客源合作
- (void)deletePassengerCooperationWithPassengerAdcrId:(NSString *)adcrId successBlock:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"adcrId":adcrId
                                 };
    
    [kNetworkManager POSTWithURLString:URL_DELETE_MY_COOPERATION_PASSENGER_DETAIL parameters:parameters success:^(id responseObject) {
        NSLog(@"6.2.4 删除我发布的客源合作: responseObject-->%@",responseObject);
        
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }

    }];
}


// 6.6.1 获取我发布的房源合作 GET请求
- (void)requestMyReleaseHouseCooperationWithsuccess:(void (^)(NSArray<SISSHouseCooperationModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId
                                 };
    
    [kNetworkManager GETWithURLString:URL_MY_RELEASE_HOUSE_COOPERATION parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.6.1 获取我发布的房源合作: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *houseResourceArr = [NSArray yy_modelArrayWithClass:[SISSHouseCooperationModel class] json:dataArr];
        if (successBlock) {
            successBlock(houseResourceArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
    
}

// 6.6.2 获取我发布的需求(客源)合作 GET请求
- (void)requestMyReleasePassengerCooperatioonWithsuccess:(void (^)(NSArray<SISSPassengerCooperationModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId
                                 };
    
    [kNetworkManager GETWithURLString:URL_MY_RELEASE_PASSENGER_COOPERATION parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.6.2 获取我发布的需求(客源)合作: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *passengerResourceArr = [NSArray yy_modelArrayWithClass:[SISSPassengerCooperationModel class] json:dataArr];
        if (successBlock) {
            successBlock(passengerResourceArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 6.7.1 获取我发布的房源合作房源详情 GET请求
- (void)requestMyReleaseHouseCooperationDetailWithCooperationId:(NSString *)houseCooperationId success:(void (^)(SISSHouseCooperationDetailModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId,
                                 @"ahcrId":houseCooperationId
                                 };
    
    [kNetworkManager GETWithURLString:URL_MY_RELEASE_HOUSE_COOPERATION_DEATAIL parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.7.1 获取我发布的房源合作房源详情: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSDictionary *dict = dataArr.firstObject;
        
        SISSHouseCooperationDetailModel *detailModel = [SISSHouseCooperationDetailModel yy_modelWithJSON:dict];
        if (successBlock) {
            successBlock(detailModel);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
    
}

// 6.7.2 获取我发布的合作需求(客源)详情 GET请求
- (void)requestMyReleasePassengerCooperatioonDetailWithCooperationId:(NSString *)passengerCooperationId success:(void (^)(SISSPassengerCooperationDetailModel *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId,
                                 @"adcrId":passengerCooperationId
                                 };
    
    [kNetworkManager GETWithURLString:URL_MY_RELEASE_PASSENGER_COOPERATION_DEATAIL parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.7.2 获取我发布的合作需求(客源)详情: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSDictionary *dict = dataArr.firstObject;
        
        SISSPassengerCooperationDetailModel *detailModel = [SISSPassengerCooperationDetailModel yy_modelWithJSON:dict];
        if (successBlock) {
            successBlock(detailModel);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 6.8.1 获取房源合作合作请求  GET请求
- (void)requestHouseCooperationCooperationRequestWithCooperationId:(NSString *)houseCooperationId success:(void (^)(NSArray<SISSAgentInfoModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"ahcrId":houseCooperationId
                                 };
    
    [kNetworkManager GETWithURLString:URL_MY_HOUSE_COOPERATION_REQUEST parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.8.1 获取房源合作合作请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *modelArr = [NSArray yy_modelArrayWithClass:[SISSAgentInfoModel class] json:dataArr];
        if (successBlock) {
            successBlock(modelArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
    
}

// 6.8.2 获取需求(客源)合作合作请求  GET请求
- (void)requestPassengerCooperatioonCooperationRequestWithCooperationId:(NSString *)passengerCooperationId success:(void (^)(NSArray<SISSAgentInfoModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"adcrId":passengerCooperationId
                                 };
    [kNetworkManager GETWithURLString:URL_MY_PASSENGER_COOPERATION_REQUEST parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.8.2 获取需求(客源)合作合作请求: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *modelArr = [NSArray yy_modelArrayWithClass:[SISSAgentInfoModel class] json:dataArr];
        if (successBlock) {
            successBlock(modelArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 6.9.1 更新房源合作请求状态请求
- (void)updateHouseCooperationCooperationRequestWithCooperationId:(NSString *)houseCooperationId agentModel:(SISSAgentInfoModel *)agentModel status:(NSInteger)status success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId,
                                 @"requestSpId":agentModel.spId,
                                 @"ahcrId":houseCooperationId,
                                 @"id":agentModel.ID,
                                 @"status":@(status)
                                 };
    
    [kNetworkManager POSTWithURLString:URL_UPDATE_HOUSE_COOPERATION_REQUEST parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.9.1 更新房源合作请求状态请求（1:同意2:不同意）%zd : responseObject-->%@",status,responseObject);
        
        if (successBlock) {
            successBlock(responseObject);
        }
        
        
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
    
}

// 6.9.2 更新客源合作请求状态请求
- (void)updatePassengerCooperatioonCooperationRequestWithCooperationId:(NSString *)passengerCooperationId agentModel:(SISSAgentInfoModel *)agentModel status:(NSInteger)status success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId,
                                 @"requestSpId":agentModel.spId,
                                 @"adcrId":passengerCooperationId,
                                 @"id":agentModel.ID,
                                 @"status":@(status)
                                 };
    
    [kNetworkManager POSTWithURLString:URL_UPDATE_PASSENGER_COOPERATION_REQUEST parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.9.2 更新客源合作请求状态请求（1:同意2:不同意）%zd : responseObject-->%@",status,responseObject);
        
        if (successBlock) {
            successBlock(responseObject);
        }
        
        
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}

// 6.10.1 获取我请求的房源合作 GET请求
- (void)requestMyRequestHouseCooperationWithsuccess:(void (^)(NSArray<SISSHouseCooperationModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId
                                 };
    
    [kNetworkManager GETWithURLString:URL_MY_REQUEST_HOUSE_COOPERATION parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.10.1 获取我请求的房源合作: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *houseCooperationArr = [NSArray yy_modelArrayWithClass:[SISSHouseCooperationModel class] json:dataArr];
        if (successBlock) {
            successBlock(houseCooperationArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
    
}

// 6.10.2 获取我请求的客源合作 GET请求
- (void)requestMyRequestPassengerCooperationWithsuccess:(void (^)(NSArray<SISSPassengerCooperationModel *> *))successBlock failed:(void (^)(NSError *))failedBlock {
    
    NSDictionary *parameters = @{
                                 @"spId":[SISSUserAccount shared].spId
                                 };
    
    [kNetworkManager GETWithURLString:URL_MY_REQUEST_PASSENGER_COOPERATION parameters:parameters success:^(id responseObject) {
        
        NSLog(@"6.10.2 获取我请求的客源合作: responseObject-->%@",responseObject);
        
        if ([responseObject[@"code"] integerValue] != 200) {
            
            NSLog(@"%@",responseObject[@"data"]);
        }
        
        NSArray *dataArr = responseObject[@"data"];
        
        NSArray *passengerCooperationArr = [NSArray yy_modelArrayWithClass:[SISSPassengerCooperationModel class] json:dataArr];
        if (successBlock) {
            successBlock(passengerCooperationArr);
        }
        
    } failure:^(NSError *error) {
        
        if (failedBlock) {
            failedBlock(error);
        }
    }];
}





@end
